
package com.joysuch.wwyt.datadump.biz.query;

import cn.zlg.common.datadump.condition.QueryCondtionDef;
import cn.zlg.common.datadump.condition.QueryFieldCondition;
import cn.zlg.common.datadump.condition.QueryFieldConditionSet;
import cn.zlg.common.datadump.condition.SortFieldDef;
import com.joysuch.wwyt.bp.entity.dsl.QBpDepart;
import com.joysuch.wwyt.bp.entity.dsl.QBpProductionFacility;
import com.joysuch.wwyt.mh.entity.dsl.QMhMajorHazard;
import com.querydsl.core.types.Order;

import java.util.Arrays;
import java.util.List;

public class MhMajorHazardDumpQueryBean implements QueryCondtionDef {


    @Override
    public List<QueryFieldConditionSet> getConditionSet() {
        QMhMajorHazard q = QMhMajorHazard.mhMajorHazard;
        return Arrays.asList(
                QueryFieldConditionSet.Builder().names("name", "nameOrCode").or(
                        new QueryFieldCondition("nameOrCode", q, q.name,
                                q.id, "contains"),
                        new QueryFieldCondition("nameOrCode", q, q.code,
                                q.id, "contains")
                ).build(),
                QueryFieldConditionSet.Builder().names("state").or(
                        new QueryFieldCondition("state", q, q.state,
                                q.id, "ne"),
                        new QueryFieldCondition("state", q, q.state,
                                q.id, "isNull")
                ).build()
        );
    }

    @Override
    public QueryFieldCondition[] getAllConditionDef() {
        return new QueryFieldCondition[] {
                new QueryFieldCondition("ids", QMhMajorHazard.mhMajorHazard, QMhMajorHazard.mhMajorHazard.id,
                        QMhMajorHazard.mhMajorHazard.id, "in"),

                new QueryFieldCondition("level", QMhMajorHazard.mhMajorHazard, QMhMajorHazard.mhMajorHazard.level,
                        QMhMajorHazard.mhMajorHazard.id, "eq"),
                };
    }

    @Override
    public SortFieldDef[] getAllSortFieldDef() {
        return new SortFieldDef[] {
                new SortFieldDef(QMhMajorHazard.mhMajorHazard.id, "id", Order.DESC, true),
                new SortFieldDef(QMhMajorHazard.mhMajorHazard.name, "name", Order.ASC)
        };
    }
}
